//q5.cpp
//The program checks whether the appearances of a digit in a number is even.
//
//Binyamin 4 Jan 2018
//================================================================================

#include<iostream>

using namespace std;

//is_even
//input: a number and a digit.
//output: are the appearances of that digit in the number are even.
bool is_even(int num, int digit)
{
	if(num<10) 
	{	
		if(num==digit) return false;
		return true;
	}
	return !(is_even(num/10, digit) != is_even(num%10, digit));
}

//1. prompt for a number and a digit.
//2. capture the number and digit.
//3. print whether the appearances of the digit in the number are even.
int main()
{
	int num, digit; //num,digit - user input.
	cout << "Please enter a number and a digit" << endl;
	cin >> num >> digit;
	if(is_even(num, digit)) cout << "The appearances of the digit are even";
	else cout << "The apperances of the number are odd";
	cout << endl;
	return 0;
}
//ouput
//Please enter a number and a digit
//3454 4
//The appearances of the digit are even
